/* 
 * File:   nWindow.cpp
 * Author: rudygodoy
 * 
 * Created on November 15, 2010, 8:17 PM
 */

#include "nWindow.h"

nWindow::nWindow(int _startx, int _starty, string _title, int _type, string _options):startx(_startx), starty(_starty), title(_title), type(_type), options(_options) {
    initscr();
    clear();
    noecho();
    cbreak();	/* Line buffering disabled. pass on everything */
    WINDOW* nwin;

    // type
    switch(type){
        case 1:
            startx = (WIDTH - M_WIDTH) / 2;
            starty = (HEIGHT - M_HEIGHT) / 2;
            nwin = newwin(M_HEIGHT, M_WIDTH, starty, startx);
            print_menu(nwin, _options, 1);
            break;
        default:
            nwin = newwin(HEIGHT, WIDTH, starty, startx);
            break;
    }

    int highlight = 1;
    int choice = 0;
    int c;

    keypad(nwin, TRUE);
    mvprintw(1, 0, _title.c_str());
    refresh();

}

void nWindow::print_menu(WINDOW* _w, string _options, int _highlight){
    	int x, y, i;

	x = 2;
	y = 2;
	box(_w, 0, 0);
	for(i = 0; i < 10; ++i)
	{	if(_highlight == i + 1) /* High light the present choice */
		{	wattron(_w, A_REVERSE);
		  mvwprintw(_w, y, x, "%s", _options[i]);
			wattroff(_w, A_REVERSE);
		}
		else
		  mvwprintw(_w, y, x, "%s", _options[i]);
		++y;
	}
	wrefresh(_w);
    return;
}

nWindow::nWindow(const nWindow& orig) {
}

nWindow::~nWindow() {
}
